﻿/* ============================================================================== 
* 功能描述：SecurityHelper 
* 创 建 者：张教主 
* 当前版本: V1.0
* 创建日期：2019/1/2 10:52:38 
* ==============================================================================*/


using System;
using System.Security.Cryptography;
using System.Text;

namespace SchoolMall.Infrastructure.Helper
{
    /// <summary>
    /// 加密帮助类
    /// </summary>
    public class SecurityHelper
    {
        /// <summary>
        /// String转MD5
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static string Str2Md5(string str)
        {
            string result = string.Empty;
            if (string.IsNullOrWhiteSpace(str))
            {
                return result;
            }
            using (MD5 md5=MD5.Create())
            {
                byte[] sourceStr = Encoding.Default.GetBytes(str);
                byte[] output = md5.ComputeHash(sourceStr);
                return BitConverter.ToString(output).ToUpper();
            }

        }
    }
}
